VERSION 5.00
Begin VB.Form frmSetupApproval 
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   4545
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   9465
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   4545
   ScaleWidth      =   9465
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame1 
      BackColor       =   &H00F7D9C2&
      Height          =   4455
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   9255
      Begin VB.CheckBox Check20 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   19
         Top             =   2865
         Width           =   195
      End
      Begin VB.Frame Frame8 
         BackColor       =   &H00F7D9C2&
         Height          =   75
         Left            =   1395
         TabIndex        =   18
         Top             =   3345
         Width           =   7650
      End
      Begin VB.CheckBox Check22 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   855
         TabIndex        =   17
         Top             =   3585
         Width           =   195
      End
      Begin VB.CheckBox Check21 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   855
         TabIndex        =   16
         Top             =   3825
         Width           =   195
      End
      Begin VB.CheckBox Check19 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   15
         Top             =   1500
         Width           =   195
      End
      Begin VB.Frame Frame7 
         BackColor       =   &H00F7D9C2&
         Height          =   75
         Left            =   1065
         TabIndex        =   14
         Top             =   300
         Width           =   7980
      End
      Begin VB.CheckBox Check18 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   13
         Top             =   540
         Width           =   195
      End
      Begin VB.CheckBox Check17 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   12
         Top             =   780
         Width           =   195
      End
      Begin VB.CheckBox Check16 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   11
         Top             =   1020
         Width           =   195
      End
      Begin VB.CheckBox Check15 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   10
         Top             =   1260
         Width           =   195
      End
      Begin VB.Frame Frame6 
         BackColor       =   &H00F7D9C2&
         Height          =   75
         Left            =   1245
         TabIndex        =   9
         Top             =   1905
         Width           =   7785
      End
      Begin VB.CheckBox Check14 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   8
         Top             =   2145
         Width           =   195
      End
      Begin VB.CheckBox Check13 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   7
         Top             =   2385
         Width           =   195
      End
      Begin VB.CheckBox Check12 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   840
         TabIndex        =   6
         Top             =   2625
         Width           =   195
      End
      Begin VB.CheckBox chkCLSI 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   5460
         TabIndex        =   5
         Top             =   795
         Width           =   195
      End
      Begin VB.CheckBox chkCLDR 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   5460
         TabIndex        =   4
         Top             =   555
         Width           =   195
      End
      Begin VB.CheckBox Check28 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   5445
         TabIndex        =   3
         Top             =   1500
         Width           =   195
      End
      Begin VB.CheckBox Check29 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   5445
         TabIndex        =   2
         Top             =   2865
         Width           =   195
      End
      Begin VB.CheckBox Check30 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Check1"
         Height          =   195
         Left            =   5445
         TabIndex        =   1
         Top             =   3825
         Width           =   195
      End
      Begin VB.Label Label58 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Never Approved if Price is less than the Average cost"
         Height          =   195
         Left            =   1140
         TabIndex        =   38
         Top             =   2865
         Width           =   4725
      End
      Begin VB.Label Label61 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Stock Availability"
         Height          =   315
         Left            =   135
         TabIndex        =   37
         Top             =   3285
         Width           =   1215
      End
      Begin VB.Label Label60 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Approved only if passed the Credit Approval"
         Height          =   195
         Left            =   1155
         TabIndex        =   36
         Top             =   3585
         Width           =   3675
      End
      Begin VB.Label Label59 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Approved only if status is Buy-out or Production"
         Height          =   195
         Left            =   1155
         TabIndex        =   35
         Top             =   3825
         Width           =   3585
      End
      Begin VB.Label Label57 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Include PDC balance in AR Credit Limit"
         Height          =   195
         Left            =   1140
         TabIndex        =   34
         Top             =   1500
         Width           =   3360
      End
      Begin VB.Label Label56 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Credit Limit"
         Height          =   315
         Left            =   180
         TabIndex        =   33
         Top             =   240
         Width           =   1215
      End
      Begin VB.Label Label55 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Always check for Credit Limit"
         Height          =   195
         Left            =   1140
         TabIndex        =   32
         Top             =   540
         Width           =   2895
      End
      Begin VB.Label Label54 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Ask for password if there are Past due"
         Height          =   195
         Left            =   1140
         TabIndex        =   31
         Top             =   780
         Width           =   2895
      End
      Begin VB.Label Label53 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Ask for password if there are Bounced Checks"
         Height          =   195
         Left            =   1140
         TabIndex        =   30
         Top             =   1020
         Width           =   3525
      End
      Begin VB.Label Label52 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Include approved SO in AR Credit Limit"
         Height          =   195
         Left            =   1140
         TabIndex        =   29
         Top             =   1260
         Width           =   3360
      End
      Begin VB.Label Label51 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Price Approval"
         Height          =   315
         Left            =   120
         TabIndex        =   28
         Top             =   1845
         Width           =   1215
      End
      Begin VB.Label Label50 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Allow Modification of Price"
         Height          =   195
         Left            =   1140
         TabIndex        =   27
         Top             =   2145
         Width           =   2895
      End
      Begin VB.Label Label49 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Allow Modification of Commission rate"
         Height          =   195
         Left            =   1140
         TabIndex        =   26
         Top             =   2385
         Width           =   2895
      End
      Begin VB.Label Label48 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Allow Modification of Discounts"
         Height          =   195
         Left            =   1140
         TabIndex        =   25
         Top             =   2625
         Width           =   2895
      End
      Begin VB.Label Label70 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Always check for Credit Limit upon Invoice"
         Height          =   195
         Left            =   5775
         TabIndex        =   24
         Top             =   795
         Width           =   3210
      End
      Begin VB.Label Label69 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Always check for Credit Limit upon DR"
         Height          =   195
         Left            =   5760
         TabIndex        =   23
         Top             =   555
         Width           =   2895
      End
      Begin VB.Label Label77 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Auto-approve of Credit Limit"
         Height          =   195
         Left            =   5760
         TabIndex        =   22
         Top             =   1500
         Width           =   3210
      End
      Begin VB.Label Label78 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Auto-approve of Price"
         Height          =   195
         Left            =   5760
         TabIndex        =   21
         Top             =   2865
         Width           =   3210
      End
      Begin VB.Label Label79 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Auto-approve of Stock Availability"
         Height          =   195
         Left            =   5760
         TabIndex        =   20
         Top             =   3825
         Width           =   3210
      End
   End
End
Attribute VB_Name = "frmSetupApproval"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Object variables





'Recordset variables
Private WithEvents rsHeader As ADODB.Recordset
Attribute rsHeader.VB_VarHelpID = -1

Public sBit As String

'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Sub SetDataValue()
    
    'Credit Checking upon Invoice/DR
    chkCLSI.Value = GetValue("CL_CHECKING_SI", 3)
    chkCLDR.Value = GetValue("CL_CHECKING_DR", 3)
    Check28.Value = GetValue("AUTOAPPROVE_CL", 3)
    Check29.Value = GetValue("AUTOAPPROVE_PRICE", 3)
    Check30.Value = GetValue("AUTOAPPROVE_STOCK", 3)

End Sub

Sub SaveChanges()
Set rs = Nothing
Set rs = New ADODB.Recordset
rs.Open "select datepart(yy,getdate()) as dDate", cn, adOpenKeyset, adLockReadOnly

    'Credit Checking upon Invoice/DR
    SetValue "CL_CHECKING_SI", 3, chkCLSI.Value
    SetValue "CL_CHECKING_DR", 3, chkCLDR.Value
    SetValue "AUTOAPPROVE_CL", 3, Check28.Value
    SetValue "AUTOAPPROVE_PRICE", 3, Check29.Value
    SetValue "AUTOAPPROVE_STOCK", 3, Check30.Value

   
     cn.BeginTrans
        rsHeader.UpdateBatch adAffectAll
    cn.CommitTrans
    MsgBox "Record/s successfully saved.", vbInformation, "ComUnion"
    Set rs = Nothing

End Sub
 
 'Close active window
Public Sub TBCloseWindow()
    Unload Me
End Sub

Private Sub Form_Activate()
    TBBitReload
End Sub

Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'SS06'")
    
    Set rsHeader = New ADODB.Recordset
    

    If rsHeader.State <> adStateOpen Then
        OpenRecordset rsHeader, "*", "SYSTEM_OPTION"
        SetDataValue
    End If
    
    TBBitReload
End Sub

Private Sub Form_Unload(Cancel As Integer)

    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True
    
    
    
    
    Set rsHeader = Nothing
    
    Set frmSetupUtil = Nothing
    
    lCloseWindow = True
    CloseMenuTab ITGLedgerMain
    
'    'oForm(Me.Tag).Mode = 1
'    'oForm(Me.Tag).Tag = Me.Tag
End Sub

'Reload menu buttons (do not delete this sub)
Public Sub TBBitReload()
    Set FrmName = Me
    BitVisible ITGLedgerMain.tbrMain, True, True
    sBit = "0000000100001000"
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
End Sub

'Save all changes
Public Sub TBSave()
       SaveChanges
End Sub


Public Function GetValue(param1 As String, param2 As Integer)
On Error GoTo TheSource
    lBoolean = True
    If rsHeader.RecordCount = 0 Then Exit Function
    rsHeader.MoveFirst
    rsHeader.Find ("cCode='" & param1 & "'")
    If param2 = 3 Then
        GetValue = IIf(rsHeader.Fields(3), 1, 0)
    Else
        GetValue = IIf(rsHeader.Fields(4) = Null, "", rsHeader.Fields(4))
    End If
    lBoolean = False
TheSource:
    If lBoolean Then
        If param2 = 3 Then GetValue = False
        If param2 = 4 Then GetValue = ""
    End If
End Function


Sub SetValue(param1 As String, param2 As Integer, param3 As String)
On Error GoTo TheSource
  
    If rsHeader.RecordCount = 0 Then Exit Sub
    rsHeader.MoveFirst
    rsHeader.Find ("cCode='" & param1 & "'")
    If param2 = 3 Then
        rsHeader.Fields(3).Value = IIf(param3 = "0", 0, 1)
    Else
        rsHeader.Fields(4).Value = param3
    End If
TheSource:
    Exit Sub
End Sub

